package com.hengpeng.itfinbase.persist;

import java.util.Date;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;

import com.hengpeng.common.persist.entity.AbstractEntity;
import com.hengpeng.common.persist.entity.AuditedEntity;
import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputPattern;
import com.hengpeng.common.web.annotation.HtmlInputType;
import com.hengpeng.itfinbase.en.PaymentGatewayType;

/**
 * <pre>
 * 支付提供商信息
 * </pre>
 * @author Administrator
 * @version 1.0, 2010-7-19
 */
@Entity
public class PaymentProvider extends AbstractEntity implements AuditedEntity
{
	/**
	 * <pre>
	 * 支付提供商状态
	 * </pre>
	 * @author zhaojitao
	 * @version 1.0, 2010-8-6
	 */
	public static enum PaymentProviderState
	{
		/**
		 * 正常开通
		 */
		OPEN("正常开通"),
		/**
		 * 暂停服务
		 */
		PAUSE("暂停服务");

		private String text;

		PaymentProviderState(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}

	/**
	 * <pre>
	 * 支付提供商类型
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2010-7-19
	 */
	public enum PaymentProviderType
	{
		/**
		 * 提现
		 */
		DRAWING("提现"),
		/**
		 * 预付款
		 */
		IMPREST("预付款");

		private String text;

		PaymentProviderType(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}

	private static final long serialVersionUID = 2927062341419041394L;

	@Column(length = 30)
	@HtmlInput(label = "资金帐户", type = HtmlInputType.TEXT, index = 16, nullable = true, tips = "付款/收款的账户")
	private String accountId;

	@HtmlInput(label = "费率(千分比)", type = HtmlInputType.TEXT, index = 5, nullable = true)
	private Integer charge;

	@HtmlInput(label = "安全校验码", type = HtmlInputType.TEXT, index = 8, nullable = true)
	private String checkKey;

	@ElementCollection(fetch = FetchType.EAGER)
	@HtmlInput(label = "额外配置信息", maxLength = 500, type = HtmlInputType.TEXTAREA, index = 99, nullable = true, inputId = "extConfigString")
	private Map<String, String> extConfigs;

	@Column(length = 20)
	@HtmlInput(label = "网关接口类型", type = HtmlInputType.SELECT, index = 3, nullable = false, labelProperty = "text")
	@Enumerated(javax.persistence.EnumType.STRING)
	private PaymentGatewayType gatewayType;

	@Id
	@Column(length = 10)
	@HtmlInput(label = "编号", type = HtmlInputType.ID, index = 1, nullable = false, tips = "四位整数")
	private String id;

	@HtmlInput(label = "最后更新的日期", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 21, nullable = true)
	private Date lastUpdateDate;

	@HtmlInput(label = "商户到期时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 22, nullable = true, tips = "到期后支付商自动停止服务, 默认永不过期")
	private Date limitDate;

	@Column(length = 1000)
	@HtmlInput(label = "描述", type = HtmlInputType.TEXT, index = 20, nullable = true)
	private String mark;

	@HtmlInput(label = "单笔支付金额上限", tips = "单位:分", type = HtmlInputType.TEXT, index = 6, nullable = true, pattern = HtmlInputPattern.INT)
	private Long maxMoney;

	@HtmlInput(label = "商户号", type = HtmlInputType.TEXT, index = 7, nullable = true)
	@Column(length = 20)
	private String merchantId;

	@HtmlInput(label = "名称", type = HtmlInputType.TEXT, index = 2, nullable = true)
	@Column(length = 20)
	private String name;

	@Column(length = 100)
	@HtmlInput(label = "支付文件保存路径", type = HtmlInputType.TEXT, index = 9, nullable = true, tips = "支付/付款文件保存在本地的绝对跟路径")
	private String payFilePath;

	@HtmlInput(label = "支付网关地址", type = HtmlInputType.TEXT, index = 10, nullable = false)
	@Column(length = 100)
	private String payUrl;

	@Column(length = 100)
	@HtmlInput(label = "支付网关查询地址", type = HtmlInputType.TEXT, index = 12, nullable = true)
	private String queryUrl;

	@Column(length = 20)
	@HtmlInput(label = "状态", type = HtmlInputType.RADIOBOX, index = 19, nullable = false, labelProperty = "text")
	@Enumerated(javax.persistence.EnumType.STRING)
	private PaymentProviderState state;

	@Column(length = 20)
	@HtmlInput(label = "类型", type = HtmlInputType.SELECT, index = 3, nullable = false, labelProperty = "text")
	@Enumerated(javax.persistence.EnumType.STRING)
	private PaymentProviderType type;

	public String getAccountId()
	{
		return accountId;
	}

	public void setAccountId(String accountId)
	{
		this.accountId = accountId;
	}

	public Integer getCharge()
	{
		return charge;
	}

	public void setCharge(Integer charge)
	{
		this.charge = charge;
	}

	public String getCheckKey()
	{
		return checkKey;
	}

	public void setCheckKey(String checkKey)
	{
		this.checkKey = checkKey;
	}

	public Map<String, String> getExtConfigs()
	{
		return extConfigs;
	}

	public void setExtConfigs(Map<String, String> extConfigs)
	{
		this.extConfigs = extConfigs;
	}

	public PaymentGatewayType getGatewayType()
	{
		return gatewayType;
	}

	public void setGatewayType(PaymentGatewayType gatewayType)
	{
		this.gatewayType = gatewayType;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public Date getLastUpdateDate()
	{
		return lastUpdateDate;
	}

	public void setLastUpdateDate(Date lastUpdateDate)
	{
		this.lastUpdateDate = lastUpdateDate;
	}

	public Date getLimitDate()
	{
		return limitDate;
	}

	public void setLimitDate(Date limitDate)
	{
		this.limitDate = limitDate;
	}

	public String getMark()
	{
		return mark;
	}

	public void setMark(String mark)
	{
		this.mark = mark;
	}

	public Long getMaxMoney()
	{
		return maxMoney;
	}

	public void setMaxMoney(Long maxMoney)
	{
		this.maxMoney = maxMoney;
	}

	public String getMerchantId()
	{
		return merchantId;
	}

	public void setMerchantId(String merchantId)
	{
		this.merchantId = merchantId;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getPayUrl()
	{
		return payUrl;
	}

	public void setPayUrl(String payUrl)
	{
		this.payUrl = payUrl;
	}

	public String getQueryUrl()
	{
		return queryUrl;
	}

	public void setQueryUrl(String queryUrl)
	{
		this.queryUrl = queryUrl;
	}

	public PaymentProviderState getState()
	{
		return state;
	}

	public void setState(PaymentProviderState state)
	{
		this.state = state;
	}

	public PaymentProviderType getType()
	{
		return type;
	}

	public void setType(PaymentProviderType type)
	{
		this.type = type;
	}

	public String getPayFilePath()
	{
		return payFilePath;
	}

	public void setPayFilePath(String payFilePath)
	{
		this.payFilePath = payFilePath;
	}

}